﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TrainingsApp.Helper;
using System.Net.Mail;
using System.Text;
using TrainingsApp.WebModel.Route;

namespace TrainingsApp.IPADApp {
    public partial class ForgetPassword : PageBase {

        public override bool IsAuthenticated {
            get {
                return false;
            }
        }

        protected void Page_Load(object sender, EventArgs e) {

        }

        protected void btnSubmit_Click(object sender, EventArgs e) {


            var userInfo = TrainingsApp.Logic.Sys_Permission_Logic.T_USER_View(this.txtUserName.Text);
            if (userInfo == null) return;
            System.Collections.Specialized.NameValueCollection newNameValueCollection = new System.Collections.Specialized.NameValueCollection();
            newNameValueCollection["#Password#"] = userInfo.Password;
            newNameValueCollection["#UserName#"] = userInfo.UserName;
            newNameValueCollection["#Root#"] = RouteManager.Root;
            newNameValueCollection["#IndexLink#"] = RouteManager.Root;

            MailHelper.Send(new MailAddress(this.txtEmail.Text, this.txtUserName.Text, Encoding.UTF8), newNameValueCollection, "请妥善保管好您的密码", "/template/mail/forgetpassword.html");
            Response.Redirect(this.RouteHelper.Route(RouteNames.Success, new { Code = SuccessCode.ForgetSuccess }));

        }
    }
}